﻿#ifndef TCPCLIENT_H
#define TCPCLIENT_H
#include <QMainWindow>
#include <QTcpServer>
#include <QTcpSocket>
#include <QNetworkInterface>
#include <QtWidgets/QPlainTextEdit>
#include "mavlink.h"
class TcpClient :public QTcpSocket
{
    Q_OBJECT
public:
    TcpClient(QObject *parent = nullptr);
    ~TcpClient();
    void connectToServer(QString ip, int port);
    void disconnectServer();
    void receiveData();
    void accCmdWrite(uint8_t);
    void (*acc_data_msg)(mavlink_message_t &msg);
    void (*acc_cali_msg)(mavlink_message_t &msg);
    mavlink_message_t & (*tx_cali_msg)();
signals:
    void received_cali();
private:
    enum
    {
        START1 = 0,
        START2,
        Receiving,
        END
    }mode;
    QByteArray data;
    int count;
//    QString clientIP;
//    quint16 clientPort;

    void receiveFailed();
    void receiveSuccess();
};

#endif // TCPCLIENT_H
